package com.rc.saas.tenant.service.invoice;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rc.saas.tenant.base.BaseSearch;
import com.rc.saas.tenant.mapper.invoice.TenantInvoiceInfoMapper;
import com.rc.saas.tenant.model.invoice.TenantInvoiceInfo;
import com.rc.saas.tenant.model.invoice.TenantInvoiceInfoExample;
import com.rc.saas.tenant.search.elec.StationInvoiceSearch;
import com.rc.saas.tenant.vo.invoice.StationInvoiceDetailExportVo;
import com.rc.saas.tenant.vo.invoice.StationInvoiceExportVo;
import com.rc.saas.tenant.vo.invoice.StationInvoiceVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author frog
 * @date 2021/4/14
 */
@Service
public class TenantInvoiceInfoServiceImpl implements TenantInvoiceInfoService {

    @Autowired
    private TenantInvoiceInfoMapper tenantInvoiceInfoMapper;

    @Override
    public TenantInvoiceInfoMapper getMapper() {
        return tenantInvoiceInfoMapper;
    }

    @Override
    public PageInfo<TenantInvoiceInfo> listPageTenantInvoiceInfo(BaseSearch baseSearch) {
        PageHelper.startPage(baseSearch.getOffset(), baseSearch.getLimit());
        TenantInvoiceInfoExample tenantInvoiceInfoExample = new TenantInvoiceInfoExample();
        tenantInvoiceInfoExample.createCriteria().andTenantCodeEqualTo(baseSearch.getTenantCode());
        List<TenantInvoiceInfo> tenantInvoiceInfos = tenantInvoiceInfoMapper.selectByExample(tenantInvoiceInfoExample);
        return new PageInfo<TenantInvoiceInfo>(tenantInvoiceInfos);
    }

    @Override
    public PageInfo<StationInvoiceVo> listPageCountStationInVoice(StationInvoiceSearch stationInvoiceSearch) {
        PageHelper.startPage(stationInvoiceSearch.getOffset(), stationInvoiceSearch.getLimit());
        List<StationInvoiceVo> stationInvoiceVOList = tenantInvoiceInfoMapper.listPageCountStationInVoice(stationInvoiceSearch);
        return new PageInfo<>(stationInvoiceVOList);
    }

    @Override
    public PageInfo<StationInvoiceVo> listPageCountStationInVoice1(StationInvoiceSearch stationInvoiceSearch) {
        PageHelper.startPage(stationInvoiceSearch.getOffset(), stationInvoiceSearch.getLimit());
        List<StationInvoiceVo> stationInvoiceVOList = tenantInvoiceInfoMapper.listPageCountStationInVoice1(stationInvoiceSearch);
        return new PageInfo<>(stationInvoiceVOList);
    }

    @Override
    public PageInfo<StationInvoiceVo> listPageCountStationInvoice2(StationInvoiceSearch stationInvoiceSearch) {
        PageHelper.startPage(stationInvoiceSearch.getOffset(),stationInvoiceSearch.getLimit());
        List<StationInvoiceVo> stationInvoiceVoList=tenantInvoiceInfoMapper.listPageCountStationInvoice2(stationInvoiceSearch);
        return new PageInfo<>(stationInvoiceVoList);
    }

    @Override
    public List<StationInvoiceDetailExportVo> listStationInvoiceDetail1(StationInvoiceSearch stationInvoiceSearch) {
        return tenantInvoiceInfoMapper.listStationInvoiceDetail1(stationInvoiceSearch);
    }

    @Override
    public List<StationInvoiceDetailExportVo> listStationInvoiceDetail2(StationInvoiceSearch stationInvoiceSearch) {
        return tenantInvoiceInfoMapper.listStationInvoiceDetail2(stationInvoiceSearch);
    }

    @Override
    public List<StationInvoiceDetailExportVo> listStationInvoiceDetail(StationInvoiceSearch stationInvoiceSearch) {
        List<StationInvoiceDetailExportVo> list = tenantInvoiceInfoMapper.listStationInvoiceDetail(stationInvoiceSearch);
        return list;
    }

    @Override
    public List<Long> listInvoiceStationId(StationInvoiceSearch stationInvoiceSearch) {
        PageHelper.startPage(stationInvoiceSearch.getOffset(), stationInvoiceSearch.getLimit());
        List<Long> list = tenantInvoiceInfoMapper.listInvoiceStationId(stationInvoiceSearch);
        return list;
    }

    @Override
    public List<StationInvoiceExportVo> listCountStationInVoice1(StationInvoiceSearch stationInvoiceSearch) {
        return tenantInvoiceInfoMapper.listCountStationInVoice1(stationInvoiceSearch);
    }

    @Override
    public List<StationInvoiceExportVo> listCountStationInVoice2(StationInvoiceSearch stationInvoiceSearch) {
        return tenantInvoiceInfoMapper.listCountStationInVoice2(stationInvoiceSearch);
    }

    @Override
    public List<StationInvoiceExportVo> listCountStationInVoice(StationInvoiceSearch stationInvoiceSearch) {
        List<StationInvoiceExportVo> list = tenantInvoiceInfoMapper.listCountStationInVoice(stationInvoiceSearch);
        return list;
    }

    @Override
    public PageInfo<StationInvoiceVo> listPageCountOperatorStationInVoice1(StationInvoiceSearch stationInvoiceSearch) {
        PageHelper.startPage(stationInvoiceSearch.getOffset(),stationInvoiceSearch.getLimit());
        List<StationInvoiceVo> list = tenantInvoiceInfoMapper.listPageCountOperatorStationInVoice1(stationInvoiceSearch);
        return new PageInfo<>(list);
    }

    @Override
    public PageInfo<StationInvoiceVo> listPageCountOperatorStationInVoice2(StationInvoiceSearch stationInvoiceSearch) {
        PageHelper.startPage(stationInvoiceSearch.getOffset(),stationInvoiceSearch.getLimit());
        List<StationInvoiceVo> list = tenantInvoiceInfoMapper.listPageCountOperatorStationInVoice2(stationInvoiceSearch);
        return new PageInfo<>(list);
    }

    @Override
    public PageInfo<StationInvoiceVo> listPageCountOperatorStationInVoice(StationInvoiceSearch stationInvoiceSearch) {
        PageHelper.startPage(stationInvoiceSearch.getOffset(),stationInvoiceSearch.getLimit());
        List<StationInvoiceVo> list=tenantInvoiceInfoMapper.listPageCountOperatorStationInVoice(stationInvoiceSearch);
        return new PageInfo<>(list);
    }

    @Override
    public List<StationInvoiceDetailExportVo> listOperatorStationInvoiceDetail1(StationInvoiceSearch stationInvoiceSearch) {
        return tenantInvoiceInfoMapper.listOperatorStationInvoiceDetail1(stationInvoiceSearch);
    }

    @Override
    public List<StationInvoiceDetailExportVo> listOperatorStationInvoiceDetail2(StationInvoiceSearch stationInvoiceSearch) {
        return tenantInvoiceInfoMapper.listOperatorStationInvoiceDetail2(stationInvoiceSearch);
    }

    @Override
    public List<StationInvoiceDetailExportVo> listOperatorStationInvoiceDetail(StationInvoiceSearch stationInvoiceSearch) {
        return tenantInvoiceInfoMapper.listOperatorStationInvoiceDetail(stationInvoiceSearch);
    }

    @Override
    public List<StationInvoiceExportVo> listCountOperatorStationInVoice1(StationInvoiceSearch stationInvoiceSearch) {
        return tenantInvoiceInfoMapper.listCountOperatorStationInVoice1(stationInvoiceSearch);
    }

    @Override
    public List<StationInvoiceExportVo> listCountOperatorStationInVoice2(StationInvoiceSearch stationInvoiceSearch) {
        return tenantInvoiceInfoMapper.listCountOperatorStationInVoice2(stationInvoiceSearch);
    }

    @Override
    public List<StationInvoiceExportVo> listCountOperatorStationInVoice(StationInvoiceSearch stationInvoiceSearch) {
        return tenantInvoiceInfoMapper.listCountOperatorStationInVoice(stationInvoiceSearch);
    }
}
